package com.dp.factory.simple_factory.service.impl;

import com.alibaba.fastjson.JSON;
import com.dp.factory.simple_factory.entity.AwardInfo;
import com.dp.factory.simple_factory.entity.ResponseResult;
import com.dp.factory.simple_factory.entity.SmallGiftInfo;
import com.dp.factory.simple_factory.service.IFreeGoods;

import java.util.UUID;

/**
 * @Author: Ruomeng
 * @Date: 2024/11/26
 * @Description : design-pattern
 * 小礼品发放服务
 * @Version: 1.0
 */
public class SmallGiftFreeGoods implements IFreeGoods {

    @Override
    public ResponseResult sendFreeGoods(AwardInfo awardInfo) {
        SmallGiftInfo smallGiftInfo = new SmallGiftInfo();
        smallGiftInfo.setUserName(awardInfo.getExtMap().get("username"));
        smallGiftInfo.setUserPhone(awardInfo.getExtMap().get("phone"));
        smallGiftInfo.setAddress(awardInfo.getExtMap().get("address"));
        smallGiftInfo.setOrderId(UUID.randomUUID().toString());
        System.out.println("发送小礼品成功!" + JSON.toJSON(smallGiftInfo));
        return new ResponseResult("200", "小礼品发送成功!", smallGiftInfo);
    }

}
